package cn.tedu.shoot;

import java.awt.image.BufferedImage;
import java.util.Random;

public class Boss extends FlyingObject implements EnemyScore {
    private int xspeed;
    private int life;

    public Boss() {
        super(380, 210);
        Random random = new Random();
        x = random.nextInt(World.WIDTH - width);
        y = 0;
        xspeed = 2;
        life = 30;
    }
    @Override
    public int getScore() {
        return 10;
    }
    @Override
    public void step() {
        x += xspeed;
        if (x <= 0 || x >= World.WIDTH - width) {
            xspeed *= -1;
        }
    }
    public BossBullet launch(){
        int xStep=this.width/16;
        int yStep=20;
        BossBullet bossBullet;
        bossBullet=new BossBullet(this.x+8*xStep,this.y+height-yStep);
        return bossBullet;
    }



    public BufferedImage getImage() {
        if (isLive()) {
            return Images.boss;
        } else if (isDead()) {
            state = REMOVE;
        }
        return null;
    }

    public void subtractLife() {
        life--;
    }

    public int getLife() {
        return life;
    }

}

